package examples.helloworldwithoutfxml

import de.saxsys.mvvmfx.InjectViewModel
import de.saxsys.mvvmfx.JavaView
import javafx.fxml.Initializable
import javafx.geometry.Insets
import javafx.scene.control.Label
import javafx.scene.layout.VBox

/**
 * Created by TK-chenbin on 2015/6/5.
 */
class HelloWorldView extends VBox implements JavaView<HelloWorldViewModel>,
        Initializable {
    private Label helloLabel = new Label()

    @InjectViewModel
    private HelloWorldViewModel viewModel

    public HelloWorldView() {
        this.children << helloLabel
        this.padding = new Insets(10)
        helloLabel.with {
            it.padding = new Insets(15)
        }
    }

    @Override
    void initialize(URL location, ResourceBundle resources) {
        helloLabel.textProperty().bind(viewModel.helloMessage)
    }
}


